<template>
	<view class="content">
		<view class="bg" v-if="datas == null">
			<image src="/static/image/child-bg.png" mode=""></image>
			<view class="top joinTop">
				<view>您还未添加孩子</view>
				<navigator hover-class="false" class="addchild" url="child-add">添加孩子<i class="iconfont iconjiantou joinIcon"></i></navigator>
			</view>
		</view>
		<view class="bg" v-else>
			<image src="/static/image/child-bg.png" mode=""></image>
			<view class="top">
				<view class="topImg"><image :src="datas.avatar" mode=""></image></view>
				<view class="clild-cont">
					<view class="child-name">{{datas.nicheng}}<view class="clild_button" @tap="switchChild">切换孩子</view></view>
					<view class="clild-info">学校：{{datas.school_name}}</view>
					<view class="clild-info">年级：{{datas.gradeName}}</view>
				</view>
			</view>
		</view>
		<view class="navList">
			<view class="navItem" :class="navIndex == index ? 'navActive':''" v-for="(item,index) in navLiat" :key="index" @tap="navClick(index)">{{item}}</view>
		</view>
		<uni-table v-if="navIndex==0" snvueform="childcourse" :stu_id="datas.student_id" ></uni-table>
		<uni-table v-if="navIndex==2" snvueform="childcourse" :stu_id="datas.student_id" :group_type="2"></uni-table>
		<myTable v-if="navIndex==3"></myTable>
		<view class="not_data" v-if="navIndex==1">
			<i class="iconfont iconzanwukecheng"></i>
			<view class="not_data_text">当前暂无课表</view>
		</view>
	</view>
</template>

<script>
	import util from '@/common/util.js';
	import uniTable from '@/components/table.vue'
	import myTable from '@/components/mytable.vue'
	export default{
		data() {
			return {
				avatar: this.defimg,
				head: false,
				datas: {},
				index: 0,
				navLiat: ['学校','辅导','私塾','自订'],
				navIndex: 0,
			}
		},
		components: {
			uniTable,
			myTable
		},
		onShow() {
			this.getChildren();
			if(this.navIndex != 0) {
				this.reload = true;
				this.page = 1;
				this.getList();
			}
		},
		onUnload(){
			this.$off('select_chidren');
		},
		onLoad() {
			this.index = uni.getStorageSync('index');
			this.$on('select_chidren',(data)=>{
				this.getChildren();
			});
		},
		methods: {
			/* navItem切换 */
			navClick(index) {
				this.navIndex=index;
			},
			/* 获取当前孩子加入的班级列表 */
			getChildren() {
				this.index = uni.getStorageSync('index');
				if(!this.index){
					this.index=0;
				}
				this.$zapi.apiPost('user/currency.Parents/childlist').then(res => {
					if(res.data.code == 200) {
						var list = res.data.data;//我加入群列表的信息
						if(list[this.index].nicheng == '') {
							list[this.index].nicheng = '未设置昵称';
						}
						list[this.index].gradeName = util.getgradeName(list[this.index].grade);
						if(list[this.index].avatar == '') {
							list[this.index].avatar = this.avatar;
						}
						this.datas = list[this.index];
					} else {
						this.datas = null
					}
					uni.setStorageSync({
						key: "currentChild",
						data: this.datas
					})
				})
			},
			/* 切换孩子 */
			switchChild() {
				uni.navigateTo({
					url: '../child/my-children'
				})
			}	
		}
	}
</script>

<style scoped>
	view{
		line-height: 1.2;
	}
	
	
	.pop_bg {
		position: fixed;
		z-index: 600;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, .5);
	}
	.pop_bg_item1 {
		position: absolute;
		right: 20upx;
		margin-top: 20upx;
		width:30%;
		background-color: #ffffff;
		border-radius: 5upx;
	}
	.pop_bg_item1:before {
		content: "";
		position: absolute;
		display: inline-block;
		border-width: 18upx;
		border-style: solid;
		border-color: white transparent transparent transparent;
		transform: rotate(180deg);
		top: -30upx;
	}
	.pop_bg_item_left:before {
		right: 5%;
	}
	.left_item {
		display: flex;
		justify-content: center;
		align-items: center;
		position: relative;
		width: 100%;
		font-size: 32upx;
		padding: 15upx 0;
		color: #333333;
	}
	.moreI{
		font-size: 40upx !important;
		margin: 0 10upx 0 0 !important;
		-webkit-text-fill-color: #333333 !important;
	}
	.uni-page-head-btn{
		margin-right: 16upx !important;
	}
	.bg{
		height: 322upx;
		width: 750upx;
	}
	.bg image{
		height: 322upx;
		width: 750upx;
		position: absolute;
	}
	.top{
		position: relative;
		display: flex;
	}
	.topImg{
		width: 100upx;
		height: 100upx;
		margin-top: 42upx;
		margin-left: 38upx;
		border-radius: 50%;
	}
	.topImg image{
		max-height: 100upx;
		max-width: 100upx;
		border-radius: 50%;
	}
	.joinTop{
		margin: 0;
		text-align: center;
		color: #FFFFFF;
		display: block;
	}
	.joinTop view{
		font-size: 36upx;
		padding-top: 60upx;
		line-height: 1;
	}
	.addchild{
		display: inline-flex;
		align-items: center;
		padding-top: 30upx !important;
		font-size: 36upx;
	}
	.joinIcon{
		background: #FFFFFF;
		font-size: 50upx !important;
		margin: 0 !important;
		padding: 0 !important;
		-webkit-background-clip: text;
		-webkit-text-fill-color: transparent;
	}
	.clild-cont{
		margin-left: 20upx;
		padding-top: 72upx;
		line-height: 1;
	}
	.child-name{
		display: flex;
		justify-content: space-between;
		color: #FFFFFF;
		font-size: 36upx;
		font-weight: bold;
		margin-bottom: 20upx;
	}
	.clild-info{
		color: #FFFFFF;
		font-size: 28upx;
		margin-bottom: 10upx;
	}
	.clild_button{
		font-weight: Regular;
		font-size: 28upx;
		padding: 14upx 18upx;
		background: #FFFFFF;
		color: #FF9900;
		margin-top: -12upx;
		position: absolute;
		right: 32upx;
	}
	.people{
		font-size: 28upx;
		font-weight: Regular;
		color: white;
		margin-top: 34upx;
	}
	.navList{
		height: 100upx;
		display: flex;
		justify-content: space-around;
		align-items: center;
		border-bottom: 20upx solid #FAFAFA;
	}
	.navItem{
		color: #666666;
		font-size: 34upx;
		display: flex;
		justify-content: center;
		line-height: 94upx;
		flex-direction: column;
		align-items: center;
	}
	.navActive{
		color: #FF9900;
		font-weight: bold;
	}
	.navActive:after{
		content: '';
		width: 28upx;
		height: 4upx;
		background: #FF9900;
	}
	.cont{
		display:flex;
		flex-wrap: wrap;
		margin-bottom: 80upx;
	}
	.cont-item{
		padding: 20upx;
		box-sizing: border-box;
		width: 250upx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-around;
		text-align: center;
		height: 200upx;
		border-right: 2upx solid #E5E5E5;
		border-top:  2upx solid #E5E5E5;
		color: #666666;
		font-size: 32upx;
	}
	.cont-item text{
		font-size: 54upx;
	}
	.cont-item:nth-child(1),
	.cont-item:nth-child(2),
	.cont-item:nth-child(3) {
		border-top: none;
	}
	.cont-item:nth-child(3n){
		border-right: 2upx solid #FFFFFF;
	}
	.cont-item:last-child{
		border-bottom: none;
	}
	.tongbu,
	.ziping,
	.kecheng,
	.kaoshi{
		color: #00D5A2;
	}
	.zhiti,
	.zuoye{
		color: #A665FB;
	}
	.zhencang,
	.zhice,
	.xueqing{
		color: #FF9900;
	}
	.qulian, .course{
		color: #00ACFE;
	}
	.habit{
		color: #00C9FF;
	}
	/* 文章 */
	.tips{
		display: flex;
		justify-content: flex-start;
		align-items: center;
		border-top: 10upx solid #FAFAFA;
		border-bottom: 30upx solid #FAFAFA;
		background: #FAFAFA;
	}
	.tipItem{
		color: #999999;
		font-size: 30upx;
		padding: 8upx 22upx;
		border: 2upx solid #CCCCCC;
		line-height: 1;
		text-align: center;
		border-radius: 26upx;
		margin-left: 30upx;
		margin-right: 10upx;
	}
	.tipActive{
		color: #FFFFFF;
		background: #FF9900;
		border: 2upx solid #FF9900;
	}
	.bottom{
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 120upx;
		box-shadow: 0px -1px 1px rgba(0,0,0,0.1);
		background: #FFFFFF;
	}
	.bottom view{
		background: #FF9900;
		text-align: center;
		color: #FFFFFF;
		font-size: 34upx;
		margin: 20upx 30upx 0;
		width: 690upx;
		height: 80upx;
		line-height: 80upx;
	}
	
	.not_data {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	
	.not_data i {
		margin-top: 20upx;
		font-size: 400upx;
		line-height: 300upx;
		color: rgba(229, 229, 229, 1);
	}
	
	.not_data_text {
		color: #C2C2C2;
		font-size: 42upx;
		line-height: 40upx;
	}
</style>
